<!-- 消息发布列表 -->
<template>
  <div class="month">
    <span v-for="(item, index) in btnArr" :key="(index)" :class="{ active: currentIndex == index }"
      @click="btnClick(index)">{{ item }}</span>
    <div class="query">
      <!-- 日期表 -->
      <el-config-provider :locale="zhCn">
        <el-date-picker unlink-panels v-model="value" type="daterange" start-placeholder="起始日期" end-placeholder="结束日期"
          :calendar-change="[Date(), Date()]" />
      </el-config-provider>
      <span>查询</span>
    </div>
  </div>
  <el-table :data="tableData.list" border stripe style="font-size: 12px;" :cell-style="{ 'text-align': 'center' }">
    <el-table-column type="index" label="序号" width="100" header-align="center" />
    <el-table-column prop = "function" label="功能" header-align="center" />
    <el-table-column prop="quantity" label="发布数量" header-align="center" />
    <el-table-column prop="proportion" label="占比" header-align="center" />
  </el-table>
</template>

<script setup>
import { onMounted, ref } from "vue"
import { Message_list } from "../../../utils/api"
// 中文
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

//功能写死

//标签
var btnArr = ref(['月份', '日期']);
var currentIndex = ref(0);
var btnClick = (index) => {
  currentIndex.value = index;
}
//日期选择框
// const value1 = ref('')
const value = ref('')

//定义响应式数据
var tableData = ref({
  list: []
})

onMounted(() => {
  Message_list().then((res) => {
    // console.log(res.data.Messagelist);
    tableData.value.list = res.data.Messagelist;
  })
})

</script>

<style lang="scss" scoped>
.month {
  width: 100%;
  // margin-bottom: 20px;
  display: flex;
  position: relative;

  span {
    display: inline-block;
    width: 50px;
    height: 30px;
    margin-bottom: 10px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    // margin-left: 1px;
    color: #666666;
    font-size: 12px;
    border: 1px solid rgba(228, 228, 228, 1);
    border-radius: 3px;
  }

  span.active {
    background-color: rgb(45, 169, 250);
    color: #fff;
  }

  .query {
    position: absolute;
    // top: 0;
    left: 130px;
    span{
      background-color: #1890ff;
      color: #fff;
      position: absolute;
      top: 0;
      margin-left: 10px;
    }
  }
}
</style>